package com.lrkj.property.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.property.domain.SitePostManag;
import com.lrkj.property.service.ISitePostManagService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 场位管理Controller
 *
 * @author yajun_ren
 * @date 2022-03-16
 */
@RestController
@RequestMapping("/property/sitePostManag")
@Api(tags = "场位管理")
public class SitePostManagController extends BaseController
{
    @Autowired
    private ISitePostManagService sitePostManagService;

    /**
     * 查询场位管理列表
     */
    @ApiOperation(value = "查询场位管理列表", notes = "查询场位管理列表")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:list')")
    @GetMapping("/list")
    public TableDataInfo list(SitePostManag sitePostManag)
    {
        startPage();
        this.changeParameter(sitePostManag.getParams());
        List<SitePostManag> list = sitePostManagService.selectSitePostManagList(sitePostManag);
        return getDataTable(list);
    }

    /**
     * 导出场位管理列表
     */
	@ApiOperation(value = "导出场位管理列表", notes = "导出场位管理列表")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:export')")
    @Log(title = "场位管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SitePostManag sitePostManag)
    {
        List<SitePostManag> list = sitePostManagService.selectSitePostManagList(sitePostManag);
        ExcelUtil<SitePostManag> util = new ExcelUtil<SitePostManag>(SitePostManag.class);
        return util.exportExcel(list, "场位管理数据");
    }

    /**
     * 获取场位管理详细信息
     */
	@ApiOperation(value = "获取场位管理详细信息", notes = "获取场位管理详细信息")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sitePostManagService.selectSitePostManagById(id));
    }

    /**
     * 新增场位管理
     */
    @ApiOperation(value = "新增场位管理", notes = "新增场位管理")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:add')")
    @Log(title = "场位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SitePostManag sitePostManag)
    {
        return toAjax(sitePostManagService.insertSitePostManag(sitePostManag));
    }

    /**
     * 修改场位管理
     */
    @ApiOperation(value = "修改场位管理", notes = "修改场位管理")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:edit')")
    @Log(title = "场位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SitePostManag sitePostManag)
    {
        return toAjax(sitePostManagService.updateSitePostManag(sitePostManag));
    }

    /**
     * 删除场位管理
     */
    @ApiOperation(value = "删除场位管理", notes = "删除场位管理")
    @PreAuthorize("@ss.hasPermi('property:sitePostManag:remove')")
    @Log(title = "场位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sitePostManagService.deleteSitePostManagByIds(ids));
    }
}
